import { ref } from 'vue';

export const useBatch = () => {
  const selectColumns = { colKey: 'row-select', type: 'multiple', width: 60 };

  const selectedRowKeys = ref([]);
  const isBatch = ref(false);

  const batch = () => {
    selectedRowKeys.value = [];
    isBatch.value = !isBatch.value;
  };

  // 表格多选改变
  const rehandleSelectChange = (value: any) => {
    selectedRowKeys.value = value;
  };

  // 批量取消
  const batchCancel = () => {
    selectedRowKeys.value = [];
    isBatch.value = false;
  };

  return { selectColumns, selectedRowKeys, isBatch, batch, rehandleSelectChange, batchCancel };
};
